package com.supms.course.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.supms.course.domain.CourseTargetItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.supms.course.domain.PaperReviewItems;
import com.supms.course.service.IPaperReviewItemsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 论文(毕设)复查评价Controller
 * 
 * @author LiangHao
 * @date 2022-03-12
 */
@RestController
@RequestMapping("/paperReviewItems")
public class PaperReviewItemsController extends BaseController
{
    @Autowired
    private IPaperReviewItemsService paperReviewItemsService;

    /**
     * 查询论文(毕设)复查评价列表
     */
    @RequiresPermissions("course:paperReviewItems:list")
    @GetMapping("/list")
    public TableDataInfo list(PaperReviewItems paperReviewItems)
    {
        startPage();
        List<PaperReviewItems> list = paperReviewItemsService.selectPaperReviewItemsList(paperReviewItems);
        return getDataTable(list);
    }

    /**
     * 导出论文(毕设)复查评价列表
     */
    @RequiresPermissions("course:paperReviewItems:export")
    @Log(title = "论文(毕设)复查评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperReviewItems paperReviewItems)
    {
        List<PaperReviewItems> list = paperReviewItemsService.selectPaperReviewItemsList(paperReviewItems);
        ExcelUtil<PaperReviewItems> util = new ExcelUtil<PaperReviewItems>(PaperReviewItems.class);
        util.exportExcel(response, list, "论文(毕设)复查评价数据");
    }

    /**
     * 获取论文(毕设)复查评价详细信息
     */
    @RequiresPermissions("course:paperReviewItems:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(paperReviewItemsService.selectPaperReviewItemsById(id));
    }

    /**
     * 新增论文(毕设)复查评价
     */
    @RequiresPermissions("course:paperReviewItems:add")
    @Log(title = "论文(毕设)复查评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperReviewItems paperReviewItems)
    {
        return toAjax(paperReviewItemsService.insertPaperReviewItems(paperReviewItems));
    }

    /**
     * 修改论文(毕设)复查评价
     */
    @RequiresPermissions("course:paperReviewItems:edit")
    @Log(title = "论文(毕设)复查评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperReviewItems paperReviewItems)
    {
        return toAjax(paperReviewItemsService.updatePaperReviewItems(paperReviewItems));
    }

    /**
     * 删除论文(毕设)复查评价
     */
    @RequiresPermissions("course:paperReviewItems:remove")
    @Log(title = "论文(毕设)复查评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paperReviewItemsService.deletePaperReviewItemsByIds(ids));
    }

    /**
     * 添加本科毕业论文(设计)复查评价（添加中间表）
     */
    @PostMapping("/addPaperReviewEval")
    public AjaxResult addPaperReviewEval(@RequestBody List<PaperReviewItems> paperReviewItemsList) {
        return toAjax(paperReviewItemsService.addPaperReviewEval(paperReviewItemsList));
    }
}
